package com.common.utils;

import com.common.enums.ResultEnum;
import lombok.Data;

@Data
public class  Result {

    /*状态码*/
    private Integer code;

    /*消息*/
    private String msg;

    /*数据*/
    private Object data;


    public static Result success(){
        Result result = new Result();
        result.setCode(ResultEnum.RESULT_SUCCESS.getCode());
        result.setMsg("success");
        result.setData(null);
        return  result;
    }

    public static Result success(String msg){
        Result result = new Result();
        result.setCode(ResultEnum.RESULT_SUCCESS.getCode());
        result.setMsg(msg);
        result.setData(null);
        return  result;
    }

    public static Result success(Object data){
        Result result = new Result();
        result.setCode(ResultEnum.RESULT_SUCCESS.getCode());
        result.setMsg("success");
        result.setData(data);
        return  result;
    }

    public static Result success(String msg,Object data){
        Result result = new Result();
        result.setCode(ResultEnum.RESULT_SUCCESS.getCode());
        result.setMsg(msg);
        result.setData(data);
        return  result;
    }


    public static Result error(){
        Result result = new Result();
        result.setCode(ResultEnum.RESULT_ERROR.getCode());
        result.setMsg("error");
        return  result;
    }

    public static Result error(String msg){
        Result result = new Result();
        result.setCode(ResultEnum.RESULT_ERROR.getCode());
        result.setMsg(msg);
        return  result;
    }

    public static Result error(String msg,Integer code){
        Result  result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return  result;
    }
}
